package _examples;

import java.awt.geom.Point2D;
import java.util.Random;

import jbotsim.Clock;
import jbotsim.Node;
import jbotsim.event.ClockListener;

public class RWPNode extends Node implements ClockListener{
	Random r=new Random();
	Point2D.Double target;
	  int step = 2;
	  int movelen=30;
	//   boolean inmove=false;
	  boolean isinit=false;
          
           int teamtype;
    public void setteamtype(int i)
    {
        teamtype=i;
    }
    
    
	
    public RWPNode(){
        //Clock.addClockListener(this, 5);
    	isinit=false;
       // target = new Point2D.Double(this.getX()-(r.nextInt(10)-5), this.getY()-(r.nextInt(10)-5));
        //System.out.print((this.getX()+"   "+(r.nextInt(10)-5))+"                 "+(this.getY())+"  "+(r.nextInt(10)-5));
    }
  
   
    public void setmove(Point2D.Double des2d, int step )
    {
    	target=des2d;
    	this.step=step;
    //	 inmove=true;
    }
    public void onClock() {
     /*	if(isinit==false)
    	{
    		  target = new Point2D.Double(this.getX()-(r.nextInt(movelen)-movelen/2), this.getY()-(r.nextInt(movelen)-movelen/2));
	          //  System.out.print((this.getX()-(r.nextInt(movelen)-movelen/2))+""+(this.getY()-(r.nextInt(movelen)-movelen/2)));
	            isinit=true;
    	}
    	else
    	{
    //	 if(inmove==true)
    //	 {
            
           
    		 this.setDirection(target);
    	    	this.move(step);
    	        if(this.distance(target)<step){
    	            target = new Point2D.Double(this.getX()-(r.nextInt(movelen)-movelen/2), this.getY()-(r.nextInt(movelen)-movelen/2));
    	          //  System.out.print((this.getX()-(r.nextInt(movelen)-movelen/2))+""+(this.getY()-(r.nextInt(movelen)-movelen/2)));
//    	            inmove=false;*/
    	        }
    //	}
    	
       
    }

